//leetcode 50 pow(x,n)
public class Test2 {
    public double myPow(double x, int n) {
        if (n < 0) return 1.0 / quickPow(x, n);
        else return quickPow(x, n);
    }

    private double quickPow(double x, int n) {
        if (n == 0) return 1.0;
        double t = quickPow(x, n / 2);
        //处理幂数的奇偶问题
        return n % 2 == 0 ? t * t : t * t * x;
    }
}
